package com.xxkfz.listener;

import com.xxkfz.message.TopicMsg;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @program: xxkfz-admin-redisson
 * @ClassName TopicListener.java
 * @author: wusongtao
 * @create: 2024-01-19 13:04
 * @description:
 * @Version 1.0
 **/
@Component
public class TopicListener implements ApplicationRunner {

    @Autowired
    private RedissonClient redissonClient;

    @Override
    public void run(ApplicationArguments args) {
        RTopic topic = redissonClient.getTopic("xxkfz_key_topic");
        topic.addListener(TopicMsg.class, (charSequence, s) -> System.err.println("收到消息：" + s));
    }


}